package main
import (
	"fmt"
	"math/rand"
)

type Person struct{
	Name string
	Age int
	Address string
}

func main() {
	slice := make([]Person,10)
	for i:=0;i<10;i++{
		p :=Person{
			Name:fmt.Sprintf("npc%d",i),
			Age:rand.Intn(100),
			Address : fmt.Sprintf("addr%d",rand.Intn(10)),
		}
		slice[i] = p
	}
	fmt.Println(slice)
	var pChan chan Person
	pChan = make(chan Person, 10)
	for _,v:=range slice{
		pChan <- v
		
	}

	close(pChan)
	
	// len :=len(pChan) 
	// for i:=0;i<cap(pChan);i++{
		
	// 	val := <- pChan
	// 	fmt.Printf("%d=%v\n",i,val)
	
	// }

	for v :=range pChan{
		fmt.Println(v)
	}
	

}